import React,{Component} from 'react';
import { Layout, Menu } from 'antd';
import {UserOutlined,SolutionOutlined,MailOutlined} from '@ant-design/icons';
import storageUtil from "../../utils/storageUtil";
import {Redirect,Link,Switch,Route} from 'react-router-dom';
import ManagerInfo from "../manager/managerInfo/managerInfo"
import Check from "./check/check";
import UndoOrders from "./undoOrders/undoOrders";
import Orders from "./orders/orders";
import Qa from "../manager/qa/qa";
import DealOrders from "./undoOrders/dealOrders/dealOrders";


class Manager extends Component{
    render () {

        const {Header, Content, Footer, Sider} = Layout;

        if (storageUtil.getServicer() == null)
            return (
                <Redirect to={'/login'}/>
            )
        else {
            const manager = storageUtil.getServicer();
            return (
                <Layout>
                    <Sider
                        style={{height: '1000px'}}
                        breakpoint="lg"
                        collapsedWidth="0"
                        onBreakpoint={broken => {
                            console.log(broken);
                        }}
                        onCollapse={(collapsed, type) => {
                            console.log(collapsed, type);
                        }}
                    >
                        <div className="logo"/>
                        <h1 style={{fontSize:'80px',marginLeft:'50px',color:'white'}}>os</h1>
                        <Menu
                            style={{}}
                            theme="dark" mode="inline" defaultSelectedKeys={['4']}>
                            <Menu.Item key="1" icon={<SolutionOutlined/>}>
                                <Link to='/manager/check'>
                                    注册审核
                                </Link>
                            </Menu.Item>
                            <Menu.Item key="2" icon={<MailOutlined />}>
                                <Link to='/manager/orders'>
                                    所有工单
                                </Link>
                            </Menu.Item>
                            <Menu.Item key="3" icon={<MailOutlined />}>
                                <Link to='/manager/undoOrders'>
                                    未完成工单
                                </Link>
                            </Menu.Item>
                            <Menu.Item key="4" icon={<UserOutlined />}>
                                <Link to='/manager/managerInfo'>
                                    {manager.username}
                                </Link>
                            </Menu.Item>
                        </Menu>
                    </Sider>
                    <Layout>
                        <Header className="site-layout-sub-header-background" style={{padding: 0}}/>
                        <Content style={{margin: '24px 16px 0'}}>
                            <div className="site-layout-background" style={{padding: 24, minHeight: 360}}>
                                <Switch>
                                    <Route path="/manager/managerInfo" component={ManagerInfo}></Route>
                                    <Route path="/manager/check" component={Check}></Route>
                                    <Route path="/manager/orders" component={Orders}></Route>
                                    <Route path="/manager/undoOrders" component={UndoOrders}></Route>
                                    <Route path="/manager/qa" component={Qa}></Route>
                                    <Route path="/manager/dealOrders" component={DealOrders}></Route>
                                    <Redirect from = "/manager" to = "/manager/managerInfo"></Redirect>
                                </Switch>
                            </div>
                        </Content>
                        <Footer style={{textAlign: 'center'}}>Ant Design ©2018 Created by Ant UED</Footer>
                    </Layout>
                </Layout>
            )
        }
    }
}

export default Manager;